package com.k2data.k2app.consumer;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextClosedEvent;
import org.springframework.stereotype.Component;

/**
 * @author cuilibo@k2data.com.cn
 */
@Component
public class AppClosedEvent implements ApplicationListener<ContextClosedEvent> {

    private final KafkaService kafkaService;

    @Autowired
    public AppClosedEvent(KafkaService kafkaService) {
        this.kafkaService = kafkaService;
    }

    @Override
    public void onApplicationEvent(ContextClosedEvent event) {
        this.kafkaService.shutdown();
    }

}
